package org.nettyServer.messageHandle;

import org.nettyServer.command.login.CS_Login;
import org.nettyServer.eunm.EMessageCode;
import org.nettyServer.messageHandle.hearteat.HeartbeatLogic;
import org.nettyServer.messageHandle.login.LoginLogic;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;

@Service
public class MessageAdapter {

    @Resource
    private LoginLogic loginLogic;

    @Resource
    private HeartbeatLogic heartbeatLogic;

    HashMap<String, MessageHandleBase> map = new HashMap<>();

    @PostConstruct
    public void init(){
        //将所有的消息处理类注册到消息处理适配器中
        map.put(EMessageCode.LOGIN.getCode(), loginLogic);
        map.put(EMessageCode.HEARTBEAT.getCode(), heartbeatLogic);
    }
    public MessageHandleBase getAdapter(String code){
        return map.get(code);
    }
}
